<template>
    <div>
        <div class='head-logo-wrap'>
            <img style='float:left' src='"../../userdefined/images/logo.png?t=" + Math.random()'/>
        </div>
        <ul class='head-nav-wrapUl' v-show='showNavTab'>
            <li v-for='(nav,index) in navList' :key=index :class='{active:nav.active}' @click='clickLiNav(index)'>
                <router-link v-bind:to='nav.link'>{{nav.text}}</router-link>
            </li>
        </ul>
        <div class='user-Info-div'>
            <head-search v-show="showNavTab"></head-search>
            <head-opera></head-opera>
        </div>
    </div>
</template>

<script>
// import headOpera from './headOperation';
// import headSearch from './headSearch'
export default {
    name: 'vhead',
    data () {
        return {};
    },
    mounted () {
        if (this.navList) {
            this.doUpdateActive();
        }
		let that = this;
		let loginOut = () => {
			let $el = document.querySelectorAll('.cus_dialog');
			for (let i = 0; i < $el.length; i++) {
				document.querySelector('body').removeChild($el[i]);
			}
			that.$store.commit('updateloginOutUrls', window.location.hash.replace('#', ''));
			that.$router.push({path: '/login'});
		};
		that.utils.refreshTimer = window.setInterval(() => {
			if (that.utils.refreshTaskOrAlarmCount) {
				that.utils.refreshTaskOrAlarmCount({targetType: 'TASK'});
			}
			if (!that.utils.websocket) {
				if (that.utils.refreshTimer) {
					that.utils.refreshTimer = clearInterval(that.utils.refreshTimer);
				}
				that.$vConfirm({
					content: '',
					confirmType: 'INFO_WARNING_ONE',
					confirm: () => {
						loginOut();
					}
				});
				return;
			}
		}, 20000);
    },
    watch: {
		$route: 'updateNavActive'
    },
    methods: {
		clickLiNav (liIndex) {
			this.resetActive(this.navList, liIndex);
		}
		// updateNavActive (newVal, oldVal) {}
    },
    computed: {

    },
    props: ['navList'],
    components: {

    }
};
</script>

<style scoped lang='scss'>

</style>
